<%-- 
  - Author: Mohtisham Salahria
  - Date: 10-April-2011
  - Copyright Notice: TRAKHEES
  - Description: form.jsp
 --%>

<%@ include file="/WEB-INF/view/include.jsp"%>
<%@ page import="ae.pcfc.etks.online.web.*"%>
<script type="text/javascript">
	$().ready(function() {
		
		//$("input:submit, input:reset, input:button, input:file").button();

		$("#AdminPersonApprove").validate({
			onfocusout : false,
			onkeyup : false,
			//onclick: false,			
			rules : {
				strActionType : "required",
				strComments : "required"				
			},

			showErrors : function(errorMap, errorList) {

				var errors = '<ul>';
				var label;
				if (errorList.length) {
					$.each(errorMap, function(name, value) {
						label = $("label[for='" + name + "']").html();
						label = value + '[' + label + ']';
						errors = errors + '<li>' + label + '</li>';

					});
					errors = errors + '</ul>';
					jAlert('error', errors, '<spring:message code="label.errormessage" />');
				}
			}

		});
		$("input[name='close']").click(function(){ 
			window.location.href='${pageContext.request.contextPath}<%=ViewPath.USER_INTERNAL_TRAKHEES_STAFF_INBOX%>/<%=PageType.LIST.getPageType()%>.htm';		
		});

	});
	
		$(function() {		
		$( "#accordion" ).accordion();	
		$( "#accordionSummary" ).accordion();	
	});
	
</script>

<div id="container" dir='<spring:message code="page.dir"/>'
	align='<spring:message code="page.align"/>'>


	<spring:hasBindErrors
		name="<%=ConstantsAdmin.CLIENT_PERSON_REGISTER_ADMIN_REVIEW_USER_DATA_REQUEST_MODEL_KEY %>">
		<script type="text/javascript">
	$(document).ready(
			function() {
				jAlert('error', '<li><form:errors path="*" delimiter="<li>"/>',
						'<spring:message code="label.errormessage" />');
			});
		</script>
	</spring:hasBindErrors>
	<div id="accordionSummary">
		<div style="clear: both"></div>
		<fieldset>
			<legend>
				<spring:message code="label.client.summary.info" />
			</legend>
		</fieldset>
		<div style="clear: both"></div>
		<br />
		<div class="t_fin-black-txt">
			<c:if
				test="${null != clientCompanySummary  and not empty clientCompanySummary}">
				<div class="fm-req">
					<label> <spring:message code="label.company.nameeng" /> </label>
					<c:out value="${clientCompanySummary.strNameENG}"></c:out>
					<br />
				</div>
				<div style="clear: both"></div>
				<div class="fm-req">
					<label> <spring:message code="label.company.namearab" /> </label>
					<c:out value="${clientCompanySummary.strNameARB}"></c:out>
					<br />
				</div>
				<div style="clear: both"></div>
				<div class="fm-req">
					<label> <spring:message code="label.company.telnooffice" />
					</label>
					<c:out value="${clientCompanySummary.strOfficeNo}"></c:out>
					<br />
				</div>
				<div style="clear: both"></div>
				<div class="fm-req">
					<label> <spring:message code="label.company.role" /> </label>
					<c:forEach items="${clientCompanySummary.SCClientCompanyRoleVO}"
						var="clientRole" varStatus="loop">
						<c:if test="${loop.index > 0 }">
							<c:out value=","></c:out>
						</c:if>
						<c:choose>
							<c:when
								test='${requestScope.requestContextAttribute.locale.language == "ar"}'>
								<c:out value="${clientRole.clientRoleArb}"></c:out>
							</c:when>
							<c:otherwise>
								<c:out value="${clientRole.clientRoleEng}"></c:out>
							</c:otherwise>
						</c:choose>

					</c:forEach>
				</div>
				<br />
				<div style="clear: both"></div>
				<div class="fm-req">
					<label> <spring:message code="label.company.emailaddress" />
					</label>
					<c:out value="${clientCompanySummary.strEmail}"></c:out>
					<br />
				</div>
				<div style="clear: both"></div>
				<div class="fm-req">
					<label> <spring:message code="label.company.websiteurl" />
					</label>
					<c:out value="${clientCompanySummary.strWebsite}"></c:out>
					<br />
				</div>
				<div style="clear: both"></div>
				<br />
				<fieldset>
					<legend>
						<spring:message code="label.company.licenseinfo" />
					</legend>
				</fieldset>
				<div style="clear: both"></div>
				<br />
				<div style="clear: both"></div>
				<div class="fm-req">
					<label> <spring:message code="label.company.lia" /> </label>
					<c:out value="${clientCompanySummary.strLicenseIssuingAuth}"></c:out>
					<br />
				</div>
				<div style="clear: both"></div>
				<div class="fm-req">
					<label> <spring:message code="label.company.lno" /> </label>
					<c:out value="${clientCompanySummary.strLicenseNumber}"></c:out>
					<br />
				</div>
				<div style="clear: both"></div>
				<div class="fm-req">
					<label> <spring:message code="label.company.lid" /> </label>
					<fmt:formatDate pattern="dd-MM-yyyy"
						value="${clientCompanySummary.strLicenseIssueDate}"></fmt:formatDate>
					<br />
				</div>
				<div style="clear: both"></div>
				<div class="fm-req">
					<label> <spring:message code="label.company.led" /> </label>
					<fmt:formatDate pattern="dd-MM-yyyy"
						value="${clientCompanySummary.strLicenseExpiryDate}"></fmt:formatDate>
					<br />
				</div>
				<div style="clear: both"></div>
			</c:if>
			<c:if
				test="${null != clientPersonSummary  and not empty clientPersonSummary}">

				<div class="fm-req">
					<label> <spring:message
							code="label.nonclient.person.register.nameENG" /> </label>
					<c:out value="${clientPersonSummary.strNameENG}"></c:out>
					<br />
				</div>
				<div style="clear: both"></div>
				<div class="fm-req">
					<label> <spring:message
							code="label.nonclient.person.register.nameARB" /> </label>
					<c:out value="${clientPersonSummary.strNameARB}"></c:out>
					<br />
				</div>
				<div style="clear: both"></div>
				<div class="fm-req">
					<label> <spring:message
							code="label.nonclient.person.register.telNoHome" /> </label>
					<c:out value="${clientPersonSummary.strHomeTel}"></c:out>
					<br />
				</div>
				<div style="clear: both"></div>
				<div class="fm-req">
					<label> <spring:message code="label.company.role" /> </label>
					<c:forEach items="${clientPersonSummary.SCClientPersonRoleVO}"
						var="clientRole" varStatus="loop">
						<c:if test="${loop.index > 0 }">
							<c:out value=","></c:out>
						</c:if>
						<c:choose>
							<c:when
								test='${requestScope.requestContextAttribute.locale.language == "ar"}'>
								<c:out value="${clientRole.clientRoleArb}"></c:out>
							</c:when>
							<c:otherwise>
								<c:out value="${clientRole.clientRoleEng}"></c:out>
							</c:otherwise>
						</c:choose>

					</c:forEach>
					<br />
				</div>
				<div style="clear: both"></div>
				<div class="fm-req">
					<label> <spring:message
							code="label.nonclient.person.register.mobNo1" /> </label>
					<c:out value="${clientPersonSummary.strMobile1}"></c:out>
					<br />
				</div>
				<div style="clear: both"></div>
				<div class="fm-req">
					<label> <spring:message
							code="label.nonclient.person.register.emailAddress" /> </label>
					<c:out value="${clientPersonSummary.strEmail}"></c:out>
					<br />
				</div>
				<div style="clear: both"></div>
				<div class="fm-req">
					<label> <spring:message
							code="label.nonclient.person.register.websiteURL" /> </label>
					<c:out value="${clientPersonSummary.strWebsite}"></c:out>
					<br />
				</div>
				<div style="clear: both"></div>
			</c:if>

		</div>
		<div style="clear: both"></div>
		<br />
		<fieldset>
			<legend>
				<spring:message code="label.user.services" />
			</legend>
		</fieldset>
		<div style="clear: both"></div>
		<div class="t_form-left t_fin-black-txt">
			<c:forEach items="${adminServiceReview}" var="serviceVO"
				varStatus="status">
				<fieldset>
					<legend>
						<c:choose>
							<c:when
								test='${requestScope.requestContextAttribute.locale.language == "ar"}'>
								<!--<spring:message code="label.servicename.arb" />
					     	-->
								<c:out value="${serviceVO.strServiceNameArb}" />
							</c:when>
							<c:otherwise>
								<c:out value="${serviceVO.strServiceNameEng}" />
							</c:otherwise>
						</c:choose>
					</legend>
				</fieldset>
				<input value="${serviceVO.strServiceID}"
					id="${serviceVO.strServiceID}" name="${serviceVO.strServiceID}"
					type="hidden" />

				<c:forEach items="${serviceVO.arrServiceAttributes}"
					var="serviceAttribute" varStatus="status">
					<div class="fm-req">
						<br /> <label> <c:choose>
								<c:when test="${serviceAttribute.strNecessisty == 'M'}">
									<span class="t_star">*</span>
								</c:when>
							</c:choose> <c:choose>
								<c:when
									test='${requestScope.requestContextAttribute.locale.language == "ar"}'>
									<c:out value="${serviceAttribute.strServiceAttributeNameARB}" />
								</c:when>
								<c:otherwise>
									<c:out value="${serviceAttribute.strServiceAttributeNameENG}" />
								</c:otherwise>
							</c:choose> </label>
						<c:out value="${serviceAttribute.strAttrValue}"></c:out>
						<br />
					</div>
				</c:forEach>



			</c:forEach>
		</div>
		<div style="clear: both"></div>
		<br />
		<fieldset>
			<legend>
				<spring:message code="label.actionhistory" />
			</legend>
		</fieldset>
		<div style="clear: both"></div>
		<br />
		<div class="t_fin-black-txt">
			<table class="t_grid-table" style="width: 100%;">
				<tr class="ui-jqgrid-labels">
					<td class="ui-state-default ui-th-column ui-th-ltr"><spring:message
							code="label.nonclient.person.register.action.date" />
					</td>
					<td class="ui-state-default ui-th-column ui-th-ltr"><spring:message
							code="label.nonclient.person.register.action.user" />
					</td>
					<td class="ui-state-default ui-th-column ui-th-ltr"><spring:message
							code="label.nonclient.person.register.action.type" />
					</td>
					<td class="ui-state-default ui-th-column ui-th-ltr"><spring:message
							code="label.department" />
					</td>
					<td class="ui-state-default ui-th-column ui-th-ltr"><spring:message
							code="label.nonclient.person.register.action.comments" />
					</td>
					<td class="ui-state-default ui-th-column ui-th-ltr"><spring:message
							code="label.register.user.notification" />
					</td>
				</tr>
				<c:choose>
					<c:when test="${empty adminActionHistory.stepActionVOs}">
						<tr>
							<td colspan="6" align="center"><spring:message
									code="msg.no.actions.found" /></td>
						</tr>
					</c:when>
					<c:otherwise>
						<c:forEach items="${adminActionHistory.stepActionVOs}"
							var="actions" varStatus="loop">
							<tr>
								<td><fmt:formatDate pattern="dd/MM/yyyy"
										value="${actions.actionDate}" />
								</td>
								<td><c:out value="${actions.strActionUser}"></c:out>
								</td>
								<td><c:choose>
										<c:when test="${actions.strActionType == 'I' }">
											<spring:message code="msg.workflow.status.in.progress" />
										</c:when>
										<c:when test="${actions.strActionType == 'A' }">
											<spring:message code="msg.workflow.status.approved" />
										</c:when>
										<c:when test="${actions.strActionType == 'R' }">
											<spring:message code="msg.workflow.status.rejected" />
										</c:when>
									</c:choose></td>
								<c:forEach items="${adminActionHistory.commentsVOs}"
									var="comments" varStatus="commentloop">
									<c:if
										test="${actions.processStep.processStepCode == comments.processStep.processStepCode}">
										<c:if
											test="${registerAdminReview.strStepName ==  comments.processStep.processStepCode}">
											<c:set property="strApplnStatus"
												target="${adminActionHistory}" value="DEPT_ACTED"></c:set>
										</c:if>
										<c:choose>
											<c:when
												test='${requestScope.requestContextAttribute.locale.language == "ar"}'>
												<td><c:out
														value="${comments.processStep.processStepDescAr}"></c:out>
												</td>
											</c:when>
											<c:otherwise>
												<td><c:out
														value="${comments.processStep.processStepDescEn}"></c:out>
												</td>
											</c:otherwise>
										</c:choose>
										<td><c:out value="${comments.strComments}"></c:out>
										</td>
										<td><c:out value="${comments.strCommentsUser}"></c:out>
										</td>
									</c:if>
								</c:forEach>
							</tr>
						</c:forEach>
					</c:otherwise>
				</c:choose>
			</table>
		</div>
		<div style="clear: both"></div>
	</div>


	<c:choose>
		<c:when test="${adminActionHistory.strApplnStatus == 'DEPT_ACTED' }">
			<div style="clear: both">
				<br />
			</div>
			<div class="fm-req">
				<label><b><spring:message
							code="client.register.application.status" />
				</b>
				</label>
				<c:choose>
					<c:when
						test='${requestScope.requestContextAttribute.locale.language == "ar"}'>
						<c:out value="${adminActionHistory.strStatusAr}" />
					</c:when>
					<c:otherwise>
						<c:out value="${adminActionHistory.strStatusEn}" />
					</c:otherwise>
				</c:choose>
			</div>
		</c:when>
		<c:when test="${adminActionHistory.strApplnStatus == 'I' }">
			<form:form name="AdminPersonApprove" id="AdminPersonApprove"
				method="POST"
				modelAttribute="<%=ConstantsAdmin.REGISTER_ADMIN_REVIEW_REQUEST_MODEL_KEY %>">
				<spring:hasBindErrors
					name="<%=ConstantsAdmin.REGISTER_ADMIN_REVIEW_REQUEST_MODEL_KEY %>">
					<script type="text/javascript">
				$(document)
						.ready(
								function() {
									jAlert(
											'error',
											'<li><form:errors path="*" delimiter="<li>"/>',
											'<spring:message code="label.errormessage" />');
								});
			</script>
				</spring:hasBindErrors>
				<%
					if (request.getAttribute(ConstantsAdmin.SUCCESS_PARAM) != null) {
				%>
				<script type="text/javascript">
				$(document)
						.ready(
								function() {
									jAlert(
											'success','<%=request
									.getAttribute(ConstantsAdmin.SUCCESS_PARAM)%>
					',
												'<spring:message code="msg.success" />');
										window.opener = 'x';
										window.close();
									});
				</script>
				<%
					}
				%>
				<div style="clear: both"></div>
				<fieldset>
					<legend>
						<spring:message code="label.admin.action" />
					</legend>
				</fieldset>
				<div style="clear: both"></div>
				<br />
				<div class="t_form-left t_fin-black-txt">
					<div class="fm-req">
						<form:label path="strActionDate">
							<span class="t_star">*</span>
							<spring:message
								code="label.nonclient.person.register.action.date" />
						</form:label>
						<fmt:formatDate pattern="dd/MM/yyyy"
							value="${registerAdminReview.strActionDate}" var="actiondate" />

						<form:input path="strActionDate" id="strActionDate"
							value="${actiondate}" size="20" maxlength="100" readonly="true" />
					</div>
					<div class="fm-req">
						<form:label path="strUserName">
							<span class="t_star">*</span>
							<spring:message
								code="label.nonclient.person.register.action.user" />
						</form:label>
						<form:input path="strUserName" id="strUserName" size="20"
							maxlength="100" readonly="true" />
					</div>
					<div class="fm-req">
						<form:label path="strActionType">
							<span class="t_star">*</span>
							<spring:message
								code="label.nonclient.person.register.action.type" />
						</form:label>
						<c:choose>
							<c:when
								test='${requestScope.requestContextAttribute.locale.language == "ar"}'>
								<form:select path="strActionType"
									items="${nonClientPersonRegisterActionTypeList}"
									id="strActionType" itemLabel="labelAr" itemValue="id"
									cssStyle="width:154px;" class="fm-opt" />
							</c:when>
							<c:otherwise>
								<form:select path="strActionType"
									items="${nonClientPersonRegisterActionTypeList}"
									id="strActionType" itemLabel="labelEn" itemValue="id"
									cssStyle="width:154px;" class="fm-opt" />
							</c:otherwise>
						</c:choose>
					</div>
					<div class="fm-req">
						<form:label path="strComments">
							<span class="t_star">*</span>
							<spring:message
								code="label.nonclient.person.register.action.comments" />
						</form:label>
						<form:textarea path="strComments" id="strComments" size="20"
							maxlength="100" style="width:190px;height:100px;" class="fm-opt" />
					</div>
					<div>
						<form:label path="strUserNotification">
							<spring:message code="label.register.user.notification" />
						</form:label>
						<form:textarea path="strUserNotification" id="strUserNotification"
							size="20" maxlength="100" style="width:190px;height:100px;"
							class="fm-opt" />
					</div>
					<div id="fm-submit" class="fm-req">
						<input type="submit" name="submit"
							value="<spring:message code="label.button.submit" />"
							class="t_btns submit" /> <input type="button" name="close"
							value="<spring:message code="label.button.close" />"
							class="t_btns submit" />
					</div>
				</div>


				<form:hidden path="strApplicationId" />
				<form:hidden path="strTaskId" />
				<form:hidden path="strIncidentNo" />
				<form:hidden path="strStepName" />
				<form:hidden path="department" />
			</form:form>
		</c:when>
		<c:otherwise>
			<div style="clear: both">
				<br />
			</div>
			<div class="fm-req">
				<label><b><spring:message
							code="client.register.application.status" />
				</b>
				</label>
				<c:choose>
					<c:when
						test='${requestScope.requestContextAttribute.locale.language == "ar"}'>
						<c:out value="${adminActionHistory.strStatusAr}" />
					</c:when>
					<c:otherwise>
						<c:out value="${adminActionHistory.strStatusEn}" />
					</c:otherwise>
				</c:choose>
			</div>
		</c:otherwise>
	</c:choose>
</div>
